package com.zzyl.nursing.dto;

import com.zzyl.nursing.domain.DeviceData;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;


@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "统计查询指标数据Dto")
public class DeviceDataPointDto {
    /**
     * 时间点（格式如："00:00"）
     */
    private String dateTime;

    /**
     * 数据值
     */
    private Double dataValue;


    /**
     * 构建按日统计数据示例
     */
    public static List<DeviceDataPointDto> dayIstance(LocalDateTime startTime){
        List<DeviceDataPointDto> list = new ArrayList<>();
        for(int i = 0; i < 24; i++){
            LocalDateTime dateTime = startTime.plusHours(i);
            list.add(new DeviceDataPointDto(dateTime.format(DateTimeFormatter.ofPattern("HH:00")),0.0));
        }
        return list;
    }

    /**
     * 构建按周统计数据示例
     */
    public static List<DeviceDataPointDto> weekInstance(LocalDateTime startTime){
        List<DeviceDataPointDto> list = new ArrayList<>();
        for(int i = 0; i < 7; i++){
            LocalDateTime dateTime = startTime.plusDays(i);
            list.add(new DeviceDataPointDto(dateTime.format(DateTimeFormatter.ofPattern("MM.dd")),0.0));
        }
        return list;
    }



}
